home *** CD-ROM | disk | FTP | other *** search
- Device Timeout (ERR=57) on Communication Ports
- by D. Thomas Mack
- August 12, 1983
-
- For those who write BASIC programs that read the IBM-PC's
- communications Ports, you will occasionally experience a DEVICE
- TIMEOUT error condition. Regretably, under the BASIC interperter
- the system will simply "lock up" with the cursor blinking in the
- upper left hand corner of the screen. If the program is
- compiled, you will get a program termination (i.e. it will
- return to DOS) with the message on the screen DEVICE TIMEOUT. The
- problem occurs when the program logic is as follows:
-
- 1416 ON ERROR GOTO 13000 'Trap error conditions
- 1420 Y$=INPUT$(1,#3) 'Read the COM1 device as file # 3
- 1425
- o
- o
- 13000 'Error Trapping ------------------------
- 13009 IF ERR=57 AND ERL=1420 THEN RESUME 1425
-
- First the DEVICE TIMEOUT condition occurs on reading a
- communication port in the PC for one of four types of errors:
-
- 1. Overrun -- the PC did not read the data in the Receive
- Buffer Register before the next character was
- put into it,
- 2. Parity -- the parity bit is set incorrectly for the number
- of data bits received,
- 3. Break -- when a break single is detected, or
- 4. Framming -- no stop bit detected following the parity bit.
-
- The last two error conditions are handled by DOS and the BASIC
- interperter with no problem. All that has to be done is to
- continue processing (i.e. line 13009 above is the correct logic).
- Error conditions 1 and 2 are the ones that present the problem
- because these indicators are not turned off in the Line Status
- Register (LSR) of the 8250 microprocessor that controls the
- IBM-PC's communications ports until the LSR is read (i.e. during
- an OPEN). If you don't want to cut somebody off by closing and
- opening the communications port, you can reset the error
- indicators in the LSR by reading the LSR. If you don't reset
- the LSR and continue processing (i.e. reading the communications
- port), you will either lock up your system under the BASIC
- interperter or return to DOS if your BASIC program has been
- compiled.
-
- However, to handle the first two conditions line 13009 should be
- changed as follows for the IBM-PC's COM1 port:
-
- 13009 IF ERR=57 AND ERL=1420 THEN R1=INP(&H3FD) RESUME 1425
-
-
- This error condition normally occurs under RBBS-PC when XMODEM
- transfers are taking place.
-